package com.example.shop.goods.dao;

import com.example.shop.goods.dto.Comments;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentsDao {
    public static final String ALL_FIELDS_SQL = " comments_id,comments_user_id,comments_content ";
    @Results(id="CommentsResultMap",value = {
            @Result(column = "comments_user_id",property = "commentsUser",
                    one = @One(select = "com.example.shop.user.dao.UserBriefInfoDao.selectById"))
    })
    @Select("select " + ALL_FIELDS_SQL +
            "from r_evaluation_comments " +
            "where evaluation_id = ${evaluationId}")
    List<Comments> selectByEvaluationId(Long evaluationId);

    @ResultMap("CommentsResultMap")
    @Select("select "+ ALL_FIELDS_SQL +
            "from r_evaluation_comments " +
            "where comments_id = ${commentsId}")
    Comments selectByCommentsId(Long commentsId);
}
